package billing.inf.helps;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

public class ObjectHelp {
	/**
	 * 判断对象是否为空
	 * 
	 * @author：lifuyu
	 * 
	 * @param obj
	 * @return
	 */
	private static boolean isEmptyImpl(Object obj)
	{
		if (obj == null)
			return true;
		if (obj instanceof String)
			return StringUtils.isBlank((String) obj);
		if (obj instanceof Map)
			return ((Map<?, ?>) obj).isEmpty();
		if (obj instanceof Collection)
			return ((Collection<?>) obj).isEmpty();
		if (obj instanceof Set)
			return ((Set<?>) obj).isEmpty();
		if (obj instanceof Object[])
			return ((Object[]) obj).length == 0;
		return false;
	}
	
	public static boolean isEmpty(Object... objs){
		boolean result = false;
		for (Object object : objs) {
			if(isEmptyImpl(object)){
				result = true;
				break;
			}
		}
		return result;
	}
}
